-- 分隔字符串
function string:split(sep)
    local sep, fields = sep or "\t", {}
    local pattern = string.format("([^%s]+)", sep)
    self:gsub(
        pattern,
        function(c)
            fields[#fields + 1] = c
        end
    )
    return fields
end

-- 字符串空判断
function string.empty(str)
    if str == nil then
        return false
    end
    return #str > 0
end

-- 首字母小写
function string.frist_lower(str)
    if str == nil or #str <= 0 then
        return ""
    end
    if #str <= 1 then
        return string.lower(str)
    end
    return string.lower(string.sub(str, 1, 1)) .. string.sub(str, 2)
end

-- 首字母大写
function string.frist_upper(str)
    if str == nil or #str <= 0 then
        return ""
    end
    if #str <= 1 then
        return string.upper(str)
    end
    return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2)
end
